<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--Rendered using the Haskell Html Library v0.2-->
<HTML
><HEAD
><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"
><TITLE
>Utility</TITLE
><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"
><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"
></SCRIPT
><SCRIPT TYPE="text/javascript"
>window.onload = function () {setSynopsis("mini_Utility.html")};</SCRIPT
></HEAD
><BODY
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="topbar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "
></TD
><TD CLASS="title"
></TD
><TD CLASS="topbut"
><A HREF="../doc/src/Utility.html"
>Source code</A
></TD
><TD CLASS="topbut"
><A HREF="index.html"
>Contents</A
></TD
><TD CLASS="topbut"
><A HREF="doc-index.html"
>Index</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="modulebar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><FONT SIZE="6"
>Utility</FONT
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="section4"
><B
>Contents</B
></TD
></TR
><TR
><TD
><DL
><DT
><A HREF="#1"
>Enum utils
</A
></DT
><DT
><A HREF="#2"
>Maybe utils
</A
></DT
><DT
><A HREF="#3"
>List utils
</A
></DT
><DT
><A HREF="#4"
>math
</A
></DT
><DT
><A HREF="#5"
>misc
</A
></DT
></DL
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Synopsis</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="#v%3Alist"
>list</A
> :: (Enum a, Bounded a) =&gt; [a]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AenumInds"
>enumInds</A
> :: Enum a =&gt; [a] -&gt; [Int]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AenumDiff"
>enumDiff</A
> :: Enum a =&gt; a -&gt; a -&gt; Int</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AnumElems"
>numElems</A
> :: (Enum a, Bounded a) =&gt; a -&gt; Int</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AcleanMaybes"
>cleanMaybes</A
> ::  String -&gt; [Maybe a] -&gt; [a]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Amaybeize"
>maybeize</A
> ::  [a] -&gt; [Maybe a]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Amonotonic"
>monotonic</A
> :: Ord a =&gt; [a] -&gt; Maybe Int</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AallIn"
>allIn</A
> :: Eq a =&gt; [a] -&gt; [a] -&gt; Bool</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AmapPairs"
>mapPairs</A
> ::  (a -&gt; a -&gt; b) -&gt; [a] -&gt; Maybe [b]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AmapPairsWrap"
>mapPairsWrap</A
> ::  (a -&gt; a -&gt; b) -&gt; [a] -&gt; [b]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Abest"
>best</A
> :: Real a =&gt; [(a, b)] -&gt; (a, b)</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Afind"
>find</A
> :: Eq a =&gt; [a] -&gt; [a] -&gt; [Maybe Int]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Aindex"
>index</A
> ::  [a] -&gt; [Maybe Int] -&gt; [Maybe a]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AsafeDoubleBang"
>safeDoubleBang</A
> ::  [a] -&gt; Maybe Int -&gt; Maybe a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AatLeast"
>atLeast</A
> ::  Int -&gt; [a] -&gt; Bool</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AbredthFirst"
>bredthFirst</A
> ::  (a -&gt; Bool) -&gt; [[a]] -&gt; a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AfindFirstAcross"
>findFirstAcross</A
> ::  (a -&gt; Bool) -&gt; [[a]] -&gt; Maybe (a, Int, Int)</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Affa_help"
>ffa_help</A
> ::  (a -&gt; Bool) -&gt; [(Int, [a])] -&gt; Int -&gt; Maybe (a, Int, Int)</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Adig"
>dig</A
> ::  (a -&gt; Bool) -&gt; [(Int, [a])] -&gt; ([a], [Int])</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AheadsTails"
>headsTails</A
> ::  [(Int, [a])] -&gt; ([(Int, [a])], [(Int, [a])])</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AfiltByKey"
>filtByKey</A
> ::  (a -&gt; Bool) -&gt; [(a, b)] -&gt; [b]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AzipMap"
>zipMap</A
> ::  (a -&gt; b) -&gt; [a] -&gt; [(b, a)]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AzipInto"
>zipInto</A
> ::  ([a] -&gt; [b]) -&gt; ([c] -&gt; [d]) -&gt; [(a, c)] -&gt; [(b, d)]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3ApairMap"
>pairMap</A
> ::  (a -&gt; b) -&gt; (c -&gt; d) -&gt; [(a, c)] -&gt; [(b, d)]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Ainterleave"
>interleave</A
> ::  [[x]] -&gt; [x]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AgenQuotRem"
>genQuotRem</A
> :: (Real a, Integral b, RealFrac c) =&gt; a -&gt; a -&gt; (b, c)</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Acumsum"
>cumsum</A
> :: Num a =&gt; [a] -&gt; [a]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AtraceIt"
>traceIt</A
> :: Show a =&gt; a -&gt; a</TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
><A NAME="1"
><A NAME="1"
>Enum utils
</A
></A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:list"
><A NAME="v%3Alist"
></A
></A
><B
>list</B
> :: (Enum a, Bounded a) =&gt; [a]</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#list"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
><P
>a list of each constructor in a <TT
>Bounded</TT
> <TT
>Enum</TT
> in successor order 
</P
><P
>call like <TT
>list::[TypeName]</TT
> or <TT
>list <TT
>asTypeOf</TT
> [TypeName]</TT
>
</P
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:enumInds"
><A NAME="v%3AenumInds"
></A
></A
><B
>enumInds</B
> :: Enum a =&gt; [a] -&gt; [Int]</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#enumInds"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>indices of <TT
>Enum</TT
> members
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:enumDiff"
><A NAME="v%3AenumDiff"
></A
></A
><B
>enumDiff</B
> :: Enum a =&gt; a -&gt; a -&gt; Int</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#enumDiff"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>number of steps up from 1st to 2nd arg in <TT
>Enum</TT
> list
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:numElems"
><A NAME="v%3AnumElems"
></A
></A
><B
>numElems</B
> :: (Enum a, Bounded a) =&gt; a -&gt; Int</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#numElems"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>cardinality of a <TT
>Bounded</TT
> <TT
>Enum</TT
> type
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
><A NAME="2"
><A NAME="2"
>Maybe utils
</A
></A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:cleanMaybes"
><A NAME="v%3AcleanMaybes"
></A
></A
><B
>cleanMaybes</B
> ::  String -&gt; [Maybe a] -&gt; [a]</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#cleanMaybes"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>un<TT
>Maybe</TT
>ize a list, error with specified message if it contains any <TT
>Nothing</TT
>s 
  won't error until a <TT
>Nothing</TT
> is actually evaluated, so we are infinite list safe
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:maybeize"
><A NAME="v%3Amaybeize"
></A
></A
><B
>maybeize</B
> ::  [a] -&gt; [Maybe a]</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#maybeize"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>apply <TT
>Just</TT
> to all members of a list
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
><A NAME="3"
><A NAME="3"
>List utils
</A
></A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:monotonic"
><A NAME="v%3Amonotonic"
></A
></A
><B
>monotonic</B
> :: Ord a =&gt; [a] -&gt; Maybe Int</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#monotonic"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
><P
><TT
>Just</TT
> +1 if list monotone ascending, <TT
>Just</TT
> -1 if monotone descending, <TT
>Just</TT
> 0 if constant (or less than 2 elements), and <TT
>Nothing</TT
> if not monotonic
</P
><P
>can't terminate if list is monotonic infinite.  otherwise efficiently fails asap.
</P
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:allIn"
><A NAME="v%3AallIn"
></A
></A
><B
>allIn</B
> :: Eq a =&gt; [a] -&gt; [a] -&gt; Bool</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#allIn"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
><P
>check if all elements of 2nd list are members of 1st list
</P
><P
>can't terminate when 2nd list is infinite list of members of 1st list.  otherwise efficiently fails asap.
</P
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:mapPairs"
><A NAME="v%3AmapPairs"
></A
></A
><B
>mapPairs</B
> ::  (a -&gt; a -&gt; b) -&gt; [a] -&gt; Maybe [b]</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#mapPairs"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>if list contains n &gt;= 2 members, return <TT
>Just</TT
> list of n-1 results of applying f to each sequential pair, otherwise <TT
>Nothing</TT
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:mapPairsWrap"
><A NAME="v%3AmapPairsWrap"
></A
></A
><B
>mapPairsWrap</B
> ::  (a -&gt; a -&gt; b) -&gt; [a] -&gt; [b]</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#mapPairsWrap"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>as mapPairs, but works for any list (and is thus not <TT
>Maybe</TT
>ized), by wrapping the pair for the final element around to the head
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:best"
><A NAME="v%3Abest"
></A
></A
><B
>best</B
> :: Real a =&gt; [(a, b)] -&gt; (a, b)</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#best"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>return pair with lowest abs key in an assoc list
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:find"
><A NAME="v%3Afind"
></A
></A
><B
>find</B
> :: Eq a =&gt; [a] -&gt; [a] -&gt; [Maybe Int]</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#find"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
><P
>list of <TT
>Just</TT
> the indices of the first elements in the 1st list that match the elements in the 2nd list, in order of the 2nd list
</P
><P
><TT
>Nothing</TT
> for elements in the 2nd list that aren't in the 1st list
</P
><P
>ex: <TT
>find &quot;abcdea&quot; &quot;ffbagdd&quot; = [Nothing,Nothing,Just 1,Just 0,Nothing,Just 3,Just 3]</TT
>
</P
><P
>compare: Data.List.elemIndex, which uses a comprehension
</P
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:index"
><A NAME="v%3Aindex"
></A
></A
><B
>index</B
> ::  [a] -&gt; [Maybe Int] -&gt; [Maybe a]</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#index"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
><P
>list of <TT
>Just</TT
> elements in the 1st list at indices specified by the 2nd list
</P
><P
><TT
>Nothing</TT
> for indices in the 2nd list that are <TT
>Nothing</TT
>, too large, or negative
</P
><P
>ex: <TT
>index &quot;abcde&quot; [Just 1,Nothing,Just 0,Just -9,Just 10] = [Just b,Nothing,Just a,Nothing,Nothing]</TT
>
</P
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:safeDoubleBang"
><A NAME="v%3AsafeDoubleBang"
></A
></A
><B
>safeDoubleBang</B
> ::  [a] -&gt; Maybe Int -&gt; Maybe a</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#safeDoubleBang"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
><P
><TT
>Maybe</TT
>ize !! to avoid runtime exception for indices that are <TT
>Nothing</TT
>, too large, or negative
</P
><P
>should use Arrays instead of lists if doing a lot of random access
</P
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:atLeast"
><A NAME="v%3AatLeast"
></A
></A
><B
>atLeast</B
> ::  Int -&gt; [a] -&gt; Bool</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#atLeast"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
><P
>safe efficient minimum list length check
</P
><P
>stolen from <A HREF="http://www.haskell.org/haskellwiki/Things_to_avoid"
>http://www.haskell.org/haskellwiki/Things_to_avoid</A
>
</P
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:bredthFirst"
><A NAME="v%3AbredthFirst"
></A
></A
><B
>bredthFirst</B
> ::  (a -&gt; Bool) -&gt; [[a]] -&gt; a</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#bredthFirst"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>search for first predicate success in a list of infinite lists
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:findFirstAcross"
><A NAME="v%3AfindFirstAcross"
></A
></A
><B
>findFirstAcross</B
></TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#findFirstAcross"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="arg"
>:: </TD
><TD CLASS="rdoc"
></TD
></TR
><TR
><TD CLASS="arg"
>=&gt; a -&gt; Bool</TD
><TD CLASS="rdoc"
></TD
></TR
><TR
><TD CLASS="arg"
>-&gt; [[a]]</TD
><TD CLASS="rdoc"
></TD
></TR
><TR
><TD CLASS="arg"
>-&gt; Maybe (a, Int, Int)</TD
><TD CLASS="rdoc"
>(successful element, list index, position index)
 wow, this is entirely out of hand -- must be some dramatically simpler way...
 see how much simpler bredthFirst is -- doesn't have to worry about empty lists, remembering match index, etc.
</TD
></TR
><TR
><TD CLASS="ndoc" COLSPAN="2"
>find the element with the lowest index in a list of lists that satisfies a predicate
</TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:ffa_help"
><A NAME="v%3Affa_help"
></A
></A
><B
>ffa_help</B
> ::  (a -&gt; Bool) -&gt; [(Int, [a])] -&gt; Int -&gt; Maybe (a, Int, Int)</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#ffa_help"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:dig"
><A NAME="v%3Adig"
></A
></A
><B
>dig</B
> ::  (a -&gt; Bool) -&gt; [(Int, [a])] -&gt; ([a], [Int])</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#dig"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>input is a predicate and a list of integers paired with (potentially empty) lists.  from the lists, collect the heads that pass the predicate, together with a list of the integer labels from the successful lists.
 |doesn't seem helpful to use Data.List.findIndices
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:headsTails"
><A NAME="v%3AheadsTails"
></A
></A
><B
>headsTails</B
> ::  [(Int, [a])] -&gt; ([(Int, [a])], [(Int, [a])])</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#headsTails"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>input is a list of integers paired with lists.  collect the heads of the lists (or empties for empties) into a list of pairs with the same integer labels.  similarly for the tails.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:filtByKey"
><A NAME="v%3AfiltByKey"
></A
></A
><B
>filtByKey</B
> ::  (a -&gt; Bool) -&gt; [(a, b)] -&gt; [b]</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#filtByKey"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>predicate filter on an assoc list
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:zipMap"
><A NAME="v%3AzipMap"
></A
></A
><B
>zipMap</B
> ::  (a -&gt; b) -&gt; [a] -&gt; [(b, a)]</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#zipMap"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>like map, but return a list of pairs (fx, x) that preserves the domain
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:zipInto"
><A NAME="v%3AzipInto"
></A
></A
><B
>zipInto</B
> ::  ([a] -&gt; [b]) -&gt; ([c] -&gt; [d]) -&gt; [(a, c)] -&gt; [(b, d)]</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#zipInto"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>take two functions that take lists to lists, apply them to a list of pairs
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:pairMap"
><A NAME="v%3ApairMap"
></A
></A
><B
>pairMap</B
> ::  (a -&gt; b) -&gt; (c -&gt; d) -&gt; [(a, c)] -&gt; [(b, d)]</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#pairMap"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>take two functions and a list of pairs, return a list of pairs of results of applications of the functions
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:interleave"
><A NAME="v%3Ainterleave"
></A
></A
><B
>interleave</B
> ::  [[x]] -&gt; [x]</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#interleave"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>bredth first interleaving of a list of infinite lists
  will error if encounters the end of any list!
  fix (the Y combinator) allows creation of recursive lambdas (http:<EM
></EM
>en.wikibooks.org<EM
>wiki</EM
>Haskell/Fix_and_recursion)
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
><A NAME="4"
><A NAME="4"
>math
</A
></A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:genQuotRem"
><A NAME="v%3AgenQuotRem"
></A
></A
><B
>genQuotRem</B
> :: (Real a, Integral b, RealFrac c) =&gt; a -&gt; a -&gt; (b, c)</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#genQuotRem"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>divide two numbers and return the nearest whole integer result, plus the fractional error
  similar to Prelude.properFraction, but minimizes magnitude of error
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:cumsum"
><A NAME="v%3Acumsum"
></A
></A
><B
>cumsum</B
> :: Num a =&gt; [a] -&gt; [a]</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#cumsum"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>cumulative sum
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
><A NAME="5"
><A NAME="5"
>misc
</A
></A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:traceIt"
><A NAME="v%3AtraceIt"
></A
></A
><B
>traceIt</B
> :: Show a =&gt; a -&gt; a</TD
><TD CLASS="declbut"
><A HREF="../doc/src/Utility.html#traceIt"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="botbar"
>Produced by <A HREF="http://www.haskell.org/haddock/"
>Haddock</A
> version 2.4.2</TD
></TR
></TABLE
></BODY
></HTML
>
